﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Core.DS;

namespace Web.Controllers
{
    public partial class datastructController : JsonController
    {
        [ValidateInput(false)]
        [NeedLogon]
        [ParamsNoEmpty]
        public ActionResult submitDSCode(int eid, int pid, int lang, string code)
        {
            return Json(status.submitDSCode(eid, pid, lang, code, Certify.username, Certify.teacherUp));
        }

        public ActionResult canSubmitDSCode(int eid)
        {
            return Json(status.canSubmitDSCode(eid));
        }

        public ActionResult getDSStatusList(int start, int limit, int eid, int? pid, string username, int? lang, int? status)
        {
            return Json(Core.DS.status.getDSStatusList(start, limit, eid, Certify.username, Certify.teacherUp, pid, username.ToQ(), lang, status));
        }

        public ActionResult getDSStatus(int rid)
        {
            return Json(status.getDSStatus(rid, Certify.username, Certify.teacherUp));
        }

        [OnlyTeacherUp]
        public ActionResult getDSTestStatus(int rid)
        {
            return Json(status.getDSTestStatus(rid));
        }

        [NeedLogon]
        public ActionResult getDSCode(int rid)
        {
            return Json(status.getDSCode(rid, Certify.username, Certify.teacherUp));
        }

        [OnlyTeacherUp]
        public ActionResult rejudgeDSStatus(int rid)
        {
            return Json(status.rejudgeDSStatus(rid));
        }

        [OnlyTeacherUp]
        public ActionResult deleteDSStatus(int rid)
        {
            return Json(status.deleteStatus(rid));
        }

        [OnlyTeacherUp]
        public ActionResult rejudgeDSProblemStatus(int eid, int pid)
        {
            return Json(status.rejudgeDSProblemStatus(eid, pid));
        }

        [OnlyTeacherUp]
        public ActionResult cleanDSProblemStatus(int eid, int pid)
        {
            return Json(status.cleanDSProblemStatus(eid, pid));
        }
    }
}
